  <!DOCTYPE html>
  <html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组去重</title>
    <script>
      // 16.  数组去重；[1,1,1,2,2,3,4,5,6,3,4,2,4,1,] ---> [1,2,3,4,5,6]
      function work16(x) {
        //创建临时中间数组
        var xsz = [];
        //循环遍历原数组
        for (let i = 0; i < x.length; i++) {
          //如果中间数组看里面没有将这个值添加进去
          if (xsz.indexOf(x[i]) === -1) {
            xsz.push(x[i]);
          }
        }
        //把去重后的数组赋值给x
        x = xsz
        //返回新的x
        return x;
      }
      //调用测试
      console.log(work16([1, 1, 1, 2, 2, 3, 4, 5, 6, 3, 4, 2, 4, 1]))
    </script>

  </head>

  <body>

  </body>

  </html>